package com.cloud.demo.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

@Configuration
public class AsyncConfig {

    @Bean("threadPoolExcutor")
    public ExecutorService executorService(){
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                4,
                8,
                2,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(),
                Executors.defaultThreadFactory()
                ,new ThreadPoolExecutor.CallerRunsPolicy()
        );
        return executor;
    }
}
